/*
 * @Author: xiaosihan 
 * @Date: 2024-10-06 20:42:55 
 * @Last Modified by: xiaosihan
 * @Last Modified time: 2024-10-06 20:44:21
 */

import { autorun } from "mobx";
import { ReactNode, useEffect, useRef, useState } from "react";
import styles from "./factoryOrder.module.less";
import FactoryHeader from "../FactoryHeader/FactoryHeader";
import factoryOrderStore from "./factoryOrderStore";
import { Button } from "antd";

interface Iprops {
    children?: ReactNode
}

// 厂商的订单
export default function FactoryOrder(props: Iprops) {
    const dom = useRef<HTMLDivElement | null>(null);
    const [data, setData] = useState({});
    const [category, setCategory] = useState(factoryOrderStore.category);
    useEffect(() => {

    }, []);

    useEffect(() => autorun(() => {
        setCategory(factoryOrderStore.category);
    }, { delay: 10 }), []);

    return (
        <div ref={dom} className={styles.factoryOrder} >
            {/* 工厂端的公共头 */}
            <FactoryHeader />
            <div className={styles.title} >订单列表</div>
            <div className={styles.btns} >
                <Button size="small" type={category === "" ? "primary" : "default"} onClick={() => factoryOrderStore.setCategory("")} >所有订单</Button>
                <Button size="small" type={category === "s1" ? "primary" : "default"} onClick={() => factoryOrderStore.setCategory("s1")}>待付款</Button>
                <Button size="small" type={category === "s2" ? "primary" : "default"} onClick={() => factoryOrderStore.setCategory("s2")} >待生产</Button>
                <Button size="small" type={category === "s3" ? "primary" : "default"} onClick={() => factoryOrderStore.setCategory("s3")} >待发货</Button>
                <Button size="small" type={category === "s4" ? "primary" : "default"} onClick={() => factoryOrderStore.setCategory("s4")} >待收货</Button>
                <Button size="small" type={category === "s5" ? "primary" : "default"} onClick={() => factoryOrderStore.setCategory("s5")} >0-100</Button>
                <Button size="small" type={category === "s6" ? "primary" : "default"} onClick={() => factoryOrderStore.setCategory("s6")} >100-1000</Button>
                <Button size="small" type={category === "s7" ? "primary" : "default"} onClick={() => factoryOrderStore.setCategory("s7")} >1000-10000</Button>
            </div>

        </div>
    );

}